<template>
    <Modal v-model="visible" width=1200>
        <div style="position: relative;height: 600px;width: 100%">
            <div id="businessTitle" style="position: relative">
                {{handleName}}
            </div>
            <Steps :current="currentTab" id="Title">
                <Step title="申请基本信息" content="" @click.native="clickStep(0)"></Step>
                <Step title="家庭成员信息" content="" @click.native="clickStep(1)"></Step>
                <Step title="模拟测评" content="" @click.native="clickStep(2)"></Step>
            </Steps>
            <div id="Content">
                <step1 ref="step1" v-if="currentTab === 0" @nextStep="nextStep" />
                <step2 ref="step2" v-if="currentTab === 1" @nextStep="nextStep" @prevStep="prevStep"/>
                <step3 ref="step3" v-if="currentTab === 2" @nextStep="nextStep" @prevStep="prevStep"/>
            </div>
        </div>
    </Modal>
</template>

<script>
    import step1 from './application1'
    import step2 from './application2'
    import step3 from './application3'
    import '@/views/common/css/common.css';
    import {CommonMixin} from '@/views/common/js/CommonMixin'

    export default {

        mixins: [CommonMixin],
        name: "index",
        components: {
            step1,
            step2,
            step3,
        },
        data() {
            return {
                key: '',
                handleName: '',
                ss02050Id: '',
                visible: false,
                currentTab: 0,
                familyInfo: this.$parent.selectedData,
                width: 800,
                height: 400,
            }
        },
        methods: {
            view(selectedData){
                let that = this;
                that.handleName = '查看测评数据';
                that.currentTab = 0
                that.visible = true;
                that.familyInfo = selectedData
                this.$nextTick(() => {
                    that.$refs.step1.formData = that.familyInfo;
                    that.$refs.step1.editOrView = true
                })
            },
            add(){
                let that = this;
                that.handleName = '录入测评数据';
                that.currentTab = 0
                that.visible = true;
                that.$refs.step1.formData = new Object();
                that.$refs.step1.editOrView = false
                that.key = this.uuid();
            },
            edit(selectedData) {
                let that = this;
                that.handleName = '编辑测评数据';
                that.currentTab = 0
                that.visible = true;
                that.familyInfo = selectedData
                this.$nextTick(() => {
                    that.$refs.step1.formData = that.familyInfo;
                    that.$refs.step1.editOrView = false
                })
            },
            nextStep() {
                if (this.currentTab == 0) {
                    this.familyInfo = arguments[0]
                    this.ss02050Id = arguments[1];
                }
                this.currentTab += 1
            },
            clickStep(currentTab) {
                if (currentTab < this.currentTab) {
                    this.currentTab = currentTab
                }
            },
            prevStep() {
                this.currentTab -= 1
                this.familyInfo = arguments[0];
            },
            finish() {
                this.familyInfo = {};
                this.currentTab = 0
            }
        }
    }
</script>

<style scoped>

    /deep/ .ivu-steps-item {
        cursor: pointer;
    }

</style>
